<?php
/**
 * 版本管理
 * 张名尊，20140508
 */ 

class versionAction extends backendAction{
    public function _initialize() {
        parent::_initialize();
        $this->_mod = D('version');
        $this->attrbuteType = 'version';
    }


    public function _before_index(){
        $this->list_relation = true;
        $bigMenu = array(
                'title' =>'添加版本',
                'iframe' => U('version/oppt',array('opttype'=>'add')),
                'id' => 'add',
                'width' => '500',
                'height' => '200'         
        );
        $this->assign('big_menu',$bigMenu);        
    }  
    
  /**
     * 版本 表增改操作
     */ 
    public function oppt(){
        
        $opptType = $this->_request('opttype','trim');
        $this->assign('opptType',$opptType);
        $this->$opptType();
    }   
    
    /**
     * apk 上传
     */ 
    public function ajax_upload_apk(){
        if (!empty($_FILES['apk']['name'])) {
        	$uploadInfo = $this->_upload($_FILES['apk'],'version');
            if($uploadInfo['error']==0){
        	    $this->ajaxReturn(1, L('operation_success'),$uploadInfo['info'][0]['savename']);            
            }else{
                $this->ajaxReturn(0,$uploadInfo['info']); 
            }    
        } else {
            $this->ajaxReturn(0, L('illegal_parameters'));
        }        
    } 
    
    protected function _search() {
        $map = array();
        ($time_start = $this->_request('time_start', 'trim')) && $map['updateTime'][] = array('egt', strtotime($time_start));
        ($time_end = $this->_request('time_end', 'trim')) && $map['updateTime'][] = array('elt', strtotime($time_end)+(24*60*60-1));
        ($keyword = $this->_request('keyword', 'trim')) && $map['name'] = array('like', '%'.$keyword.'%');
        $this->assign('search', array(
            'time_start' => $time_start,
            'time_end' => $time_end,         
            'keyword' => $keyword,
        ));
        return $map;
    }      
}
?>